﻿<%@ Page Language="C#" MasterPageFile="~/member/mMenber.master" AutoEventWireup="true" CodeBehind="pfriends.aspx.cs" Inherits="map.member.pfriends" Title="我的好友" %>

<%@ Register Assembly="RuleCode.Common" Namespace="RuleCode.Controls" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head2" runat="server">
      <link href="../outstyle.css" rel="stylesheet" type="text/css" />
      <link href="../Stylesheet1.css" rel="stylesheet" type="text/css" />
      <script src="../js/dropdowncontent.js" type="text/javascript"></script>
      <style type="text/css">
         .DataListHeaderToolTable
         {
             background-color:#ECECEC;
             width:100%;
             margin-bottom :2px;
         }
         .DataListHeaderTable
         {
             width:100%;
             height:20px;
             background-color:lightGray;
         }
         .DataListContentTable
         {
             width:100%;
         }
         .DataListHeaderTable td,.DataListContentTable td
         {
             text-align:left;
         }
         .DataListPager
         {
             background-color:lightGray;
         }
         .SystemTableTd
         {
             width:50%;
             height:300px;
         }
         .EditInfoGuideDiv
         {
             background:url(../img/editinfo.png) no-repeat;
             padding-left:40px;             
         }
         .recommendFriendsInfoDiv
         {
             border:solid 1px #ECECEC;
             width:90%; 
         }
         .recommendFriendsInfoDivtable
         {
             width:100%;
         }
         .recommendFriendsInfoDiv   a
         {
             color :Blue;
         }
         .recommendFriendsInfoDivli 
         {
             display:inline;
             list-style-type:none;
         }
         .recommendFriendsHeaderLeftTd
         {
             text-align:left;
             width:90%;
         }
         .recommendFriendsHeaderRightTd
         {
             text-align:left ;
             width:10%;
         }
         .recommendFriendsBodyTd
         {
             width:25%;
             text-align:left ;
         }
         .recommendFriendsSingleTable
         {
             width:200px;
         }
         .recommendFriendsSingleTable td img
         {
             width:40px;
             height:40px;
         }
         .hiddenObject
         {
             visibility:hidden;
         }
         .input-button,.input-submit{background-color:#005eac;border-color:#b8d4e8 #124680 #124680 #b8d4e8;border-style:solid;border-width:1px;color:#fff;cursor:pointer;font-size:12px;padding:2px 15px;text-align:center}
      </style>
    <link href="../css/popup.css" rel="stylesheet" type="text/css" />
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
    <div id="MasterDiv">
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
           
            <%--好友列表--%>
            <div style=" width:90%; border:solid 1px #ECECEC">
                <%--工具栏--%>
                <table  class="DataListHeaderToolTable">
                    <tr>
                        <td style=" width:150px; text-align:center;">
                            <asp:CheckBox ID="SelectAllCheckBox" Text=" 全选 " AutoPostBack="true"  
                                runat="server" oncheckedchanged="SelectAllCheckBox_CheckedChanged" />                        
                            <asp:CheckBox ID="SelectOthersCheckBox" Text=" 反选 " AutoPostBack="true"  
                                runat="server" oncheckedchanged="SelectOthersCheckBox_CheckedChanged" />
                        </td>
                        <td style=" width:100px;text-align:center;">                             
                            <asp:Button ID="DeleteSelectedFriendsButton" runat="server" Text="删除好友" 
                                onclick="DeleteSelectedFriendsButton_Click" />
                        </td>
                        <td style =" text-align:right ">
                            <asp:DropDownList ID="FriendsCateDropDownList" AutoPostBack ="true" 
                                OnSelectedIndexChanged ="FriendsCateDropDownList_SelectedIndexChanged" Width="150px" runat="server">
                                <asp:ListItem Value ="">全部好友分类</asp:ListItem>
                            </asp:DropDownList>
                            <a href ="FriendGroups.aspx">查看我的好友分组</a> 
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
                <%--列表头--%>
                <table width="100%"  class ="DataListHeaderTable">
                    <tr>
                        <td style=" width:5%"></td>
                        <td style=" width:10%;"></td>
                        <td style=" width:15%">Email</td>
                        <td style=" width:15%">姓名</td>
                        <td style=" width:15%">备注名称</td>
                        <td style=" width:10%">所属组</td>
                        <td style=" width:15%"><span style="color:red">Ta</span> 的博客</td>
                        <td style=" width:10%">聊天</td>
                        <td style=" width:10%">编辑</td>
                    </tr>
                </table>
                
                <asp:DataList ID="FriendsDataList" Width="100%" DataKeyField ="grouplist_RECID" runat="server">
                    <ItemTemplate>
                        <table  class="DataListContentTable" style=" height:80px; border-bottom:solid 1px lightGray" onmouseover ="this.bgColor='lightBlue';" onmouseout ="this.bgColor='white';">
                             <tr>
                                <td style=" text-align:center; width:5%">
                                    <asp:CheckBox ID="CheckBox0" runat="server" />
                                </td>
                                <td style=" width:10%;">
                                    <a target="_blank" href ='<%#"FriendInfo.aspx?id="+Eval("f_RECID").ToString() %>'><img style =" width:70px; height :70px;" src='<%#(Eval("cbimgpath").ToString()!="")?Eval("cbimgpath").ToString():"../img/userdefaultimg.gif" %>'/></a>
                                </td>
                                <td style=" width:15%">
                                    <a target="_blank" href ='<%#"FriendInfo.aspx?id="+Eval("f_RECID").ToString() %>' title ='<%#Eval("f_cbuserid").ToString() %>'> <%#(Eval("f_cbuserid").ToString().Length > 10) ? (Eval("f_cbuserid").ToString().Substring (0,10)+"...") : Eval("f_cbuserid").ToString()%></a>
                                </td>
                                <td style=" width:15%">
                                    <a href="#"> <%#Eval("f_cbname")%></a>
                                </td>
                                <td style=" width:15%">
                                    <a href="#"> <%#Eval("my_f_cbname")%></a>                                      
                                </td>
                                <td style=" width:10%">
                                    <a href="FriendGroups.aspx" title="查看好友分组" target="_blank"> <%#Eval("my_groupname")%></a>
                                </td>
                                <td style=" width:15%">
                                    <a target="_blank" href ='<%#"http://"+Eval("f_RECID").ToString()+".blog.f980.com/" %>'><span style="color:red"><%#Eval("f_cbname")%></span> 的博客</a>
                                </td>
                                <td style=" width:10%">
                                    <%# RuleCode.Table.cbuser.getChatStr (Eval("f_RECID").ToString ()) %>
                                    <%--<a target="_blank" href ='<%#"../usercate/DynamicChat.aspx?torecid="+Eval("f_RECID").ToString() %>'><%# (Eval ("f_chatIsOnLine").ToString ()=="1")?"在线":"不在线" %></a>--%>
                                </td>
                                <td style=" width:10%">
                                    <a href="#" title ="编辑好友信息" onclick ="showEditFriendInfoDiv(this);"><img  style="border:none" alt="编辑" src ="../img/edititem.gif"/></a>
                                    <input  value ='<%#Eval("grouplist_RECID").ToString() %>' type ="hidden" />
                                    <input type="hidden" value ='<%# (Eval("cbimgpath").ToString()!="")?Eval("cbimgpath").ToString():"../img/userdefaultimg.gif"%>'/>
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:DataList>
                
                <div id="NoFriendsDataDiv" style =" width:100%; background-color:#FCFBCC;   margin-top:2px; margin-bottom:2px; display:none;" runat="server">
                    <span style="color:red;font-size:small;">对不起，没有找到符合您要求的朋友！</span>
                </div>
                <div class ="DataListPager">
                    <cc1:WebPager ID="FriendsWebPager" PageSize ="10" OnPageIndexChanged ="FriendsWebPager_PageIndexChanged"
                    ControlToPaginate ="FriendsDataList" PagerStyle="NumericPages" runat="server" />
                </div>
               
                <%--分页控件--%>                 
            </div>            
            <asp:Button ID="UpdateBindButton"  CssClass ="hiddenObject" runat="server" Text="刷新"  OnClick ="UpdateBindButton_Click"/>
        </ContentTemplate>
    </asp:UpdatePanel>
            <br />
             
            <%--搜索朋友--%>
            <div>
                <div style =" float :left ;">
                    <img  src ="../img/guide4.png"/>
                </div>
                <div style =" padding-left:40px;">
                    <h2 style =" color:#3300CC">找到您的朋友们</h2>
                    <input type ="text" id="searchKeysInputText" value ="可输入姓名 学校 单位"  onblur ="if(this.value=='') this.value='可输入姓名 学校 单位';"  onfocus ="if(this.value=='可输入姓名 学校 单位')this.value='';"/>
                    <input  type ="button" class="input-button" value="搜索" onclick="searchKeysButtonClick();"/>
                    <a href ="advanceSearch.aspx" style=" padding-top:2px;color:#3300CC">高级搜索</a>
                </div>
            </div>
            <br />
            <%--系统推荐好友--%>
            <div>
                <div  class ="EditInfoGuideDiv">
                    <h3 style ="color:#3300CC">完善您的个人信息</h3>
                    <span>完善资料，这里会尽可能显示您认识的人。 <a href="pinfo.aspx">立即编辑资料 >></a></span>
                </div>
                <hr  style =" background-color:lightBlue; margin-top:10px; width:90%; text-align:left;"/>
                <br />
                <div id="SystemCommendFriendsDiv">
                
                </div>
            </div>
        </div>    
           <%--添加好友--%>
        <div class="sample_popup" id="popup" style=" position:absolute ; height:200px; width :400px; z-index :2;  display :none; ">
            <div class="menu_form_header" id="popup_drag">
                <table>
                    <tr>
                        <td>
                            添加好友：
                        </td>
                        <td>
                            <img alt="" class="menu_form_exit" onclick="document.getElementById('popup_exit').click()"  src="../img/closes.png" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="menu_form_body">    
                <div style =" width :100%;">
                    <table width="100%">
                        <tr>
                            <td style =" width:200px;">
                                <table width="200px">
                                    <tr>
                                        <td colspan="2">
                                            您将添加 <a id="NewFriendIdAnchor" style=" text-decoration:underline" href ="#"></a>为好友
                                            <input type ="hidden"  value="" id="NewFriendIdHiddenInput" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  >
                                            <span style =" text-align :left ">选择分组：</span>
                                        </td>
                                        <td>
                                            <select id="NewFriendGroupSelect">
                                                <option value ="" selected ="true">请选择分组</option>
                                            </select>
                                        </td>
                                    </tr>                        
                                    <tr>
                                        <td >
                                            <span style =" text-align :left ">备注名称(可选)：</span>
                                        </td>
                                        <td style =" text-align:left">
                                            <input id="FriendNickText" type="text" style="width: 100px" />
                                        </td>
                                    </tr>
                                </table>                                         
                            </td>
                            <td style =" width:100px; text-align:center;">
                                <img  style =" padding-top:10px; width:80px; height :80px;" id="NewFriendImg"/>
                            </td>
                        </tr>
                    </table>                             
                </div>
                <div style="text-align: center;  width: 100%">
                    <input id="AddButton" type="button" value="增加" onclick=" if( addFriend()==true) document.getElementById('popup_exit').click();" />
                    <input id="popup_exit" type="button" value="取消" />
                </div>
                <%-- <input id="GroupIdHidden" type="hidden"  />--%>
            </div>
        </div>
        
        <%--编辑好友--%>
        <div class="sample_popup" id="edit_popup" style=" position:absolute ; height:200px; width :400px; z-index :2;  display :none; ">
            <div class="menu_form_header" id="edit_popup_drag">
                <table>
                    <tr>
                        <td>
                            编辑好友信息：
                        </td>
                        <td>
                            <img alt="" class="menu_form_exit"  src="../img/closes.png"  onclick="document.getElementById('edit_popup_exit').click()" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="menu_form_body">    
                <div style =" width :100%;">
                    <table width="100%">
                        <tr>
                            <td style =" width:200px;">
                                <table width="200px">
                                    <tr>
                                        <td colspan="2">
                                            您正在编辑好友 <a id="EditFriendNameAnchor" style=" text-decoration:underline" href ="#"></a>的信息
                                            <input type ="hidden"  value="" id="EditFriendGroupListIdHidden" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  >
                                            <span style =" text-align :left ">原来分组为：</span>
                                        </td>
                                        <td>
                                            <select disabled ="true" id="EditFriendGroupOldSelect">
                                                <option value ="" selected ="true">请选择分组</option>
                                            </select>
                                        </td>
                                    </tr>  
                                    <tr>
                                        <td  >
                                            <span style =" text-align :left ">分组修改为：</span>
                                        </td>
                                        <td>
                                            <select id="EditFriendGroupNewSelect">
                                                <option value ="" selected ="true">请选择分组</option>
                                            </select>
                                        </td>
                                    </tr>                        
                                    <tr>
                                        <td >
                                            <span style =" text-align :left ">原来备注名称：</span>
                                        </td>
                                        <td style =" text-align:left">
                                            <input id="EditFriendOldNickText" disabled ="true" type="text" style="width: 100px" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td >
                                            <span style =" text-align :left ">备注名称修改：</span>
                                        </td>
                                        <td style =" text-align:left">
                                            <input id="EditFriendNewNickText"  type="text" style="width: 100px" />
                                        </td>
                                    </tr>
                                </table>                                         
                            </td>
                            <td style =" width:100px; text-align:center;">
                                <img  style =" padding-top:10px; width:80px; height :80px;" id="EditFriendImg"/>
                            </td>
                        </tr>
                    </table>                             
                </div>
                <div style="text-align: center;  width: 100%">
                    <input  type="button" value="修改" onclick=" if( editFriend()==true) document.getElementById('edit_popup_exit').click();" />
                    <input  type="button" id="edit_popup_exit" value="取消" />
                </div>
                <%-- <input id="GroupIdHidden" type="hidden"  />--%>
            </div>
        </div> 
    <div id="maskDiv" style =" position :absolute ;top:0px; left :0px;   visibility :hidden ; background-color :#666;  z-index :1;"></div>
    

    <script src="../js/PopupDiv.js" type="text/javascript"></script>
    <script type="text/javascript" >
        var updatePanelPrefix = "ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder3_";
        function updateBindPager() {
            document.getElementById(updatePanelPrefix + "UpdateBindButton").click();
        }

        var searchKeysInputText = document.getElementById("searchKeysInputText");
        searchKeysInputText.onkeydown = function(o) {
            o = o || window.event;
            if (o.keyCode == "13") {
                searchKeysButtonClick();
            }
        }
        function searchKeysButtonClick() {
            var searchKeys = document.getElementById("searchKeysInputText").value;
            if (searchKeys == "可输入姓名 学校 单位") {
                searchKeys = "";
            }
            window.location.href = "searchFriends.aspx?type=0&searchkeys=" + encodeURI(searchKeys);
        }
        
        function initSystemRecommendFriends() {
            var systemcommendfriendsdiv = document.getElementById("SystemCommendFriendsDiv");
            systemcommendfriendsdiv.innerHTML = "";

            
            var personalInfosResult = AjaxFunction.GetPersonalRelationInfo("");
            if (personalInfosResult.value == null || personalInfosResult.value == "") {
                systemcommendfriendsdiv.innerHTML = "<span style=\"color:red\">对不起，未找到您可能认识的人！</span>";
            }
            else{
                var personalInfos = eval( personalInfosResult.value );
                for (var i = 0; i < personalInfos.length; i++) {

                    var searchTypeText = "";
                    switch (personalInfos[i].Type) {
                        case "1":
                            {
                                searchTypeText = "初中";
                                break;
                            }
                        case "2":
                            {
                                searchTypeText = "高中";
                                break;
                            }
                        case "3":
                            {
                                searchTypeText = "大学";
                                break;
                            }
                        case "4":
                            {
                                searchTypeText = "单位";
                                break;
                            }
                        default:
                            {
                                break;
                            }
                    }
                    
                    if (personalInfos[i].Name == "")
                        continue ;
                    var colCount = 4;
                    var rowCount = 0;
                    var searchFriendsResult = AjaxFunction.SearchPosibleFriends(personalInfos[i].Type, personalInfos[i].Name, personalInfos[i].Year, 8);
                    var searchFriends = new Array();
                    if (searchFriendsResult.value != null && searchFriendsResult.value != "")
                        searchFriends = eval(searchFriendsResult.value);
                    var totalCount = Math.min(searchFriends.length, 2 * colCount);
                    rowCount = parseInt(totalCount / colCount);
                    
                    var newDivEle = document.createElement("div");
                    newDivEle.className = "recommendFriendsInfoDiv";
                    newDivEle.style.width = "90%";
                    
                    var newTableEle = document.createElement("table");
                    newTableEle.className = "recommendFriendsInfoDivtable";
                    newTableEle.style.width = "100%";

                    var newTrEle = document.createElement("tr");
                    
                    var newTdEle = document.createElement("td");
                    newTdEle.innerHTML = "我们在 <a href=\"#\" title=\""+searchTypeText +"\" style=\"color:blue\">" + personalInfos[i].Name +"</a> 为您找到了 "+(searchFriends.length).toString()+"位"+((personalInfos[i].Type=="4")?"同事":"同学");
                    newTdEle.className = "recommendFriendsHeaderLeftTd";
                    newTrEle.appendChild(newTdEle);

                    newTdEle = document.createElement("td");
                    newTdEle.className = "recommendFriendsHeaderRightTd";
                    var anchorEle = document.createElement("a");
                    anchorEle.innerHTML = "更多...";
                    anchorEle.href = "pfriendsRel.aspx?type=" + personalInfos[i].Type;
                    if(totalCount >2*colCount )
                        newTdEle.appendChild(anchorEle);

                    newTrEle.appendChild(newTdEle);
                    
                    newTableEle.appendChild(newTrEle);

                    newDivEle.appendChild(newTableEle);

                    newTableEle = document.createElement("table");
                    
                    if (totalCount % colCount > 0)
                        rowCount++;
                    var index = 0;
                    for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
                        newTrEle  = document.createElement("tr");
                        for (var colIndex = 0; colIndex < colCount; colIndex++) {
                            newTdEle  = document.createElement("td");
                            if (index < totalCount) {
                                var bodyHtml = "<table style=\"width:200px;\" class=\"recommendFriendsSingleTable\"><tr>"
                                bodyHtml += "<td>";
                                bodyHtml += "<a href=\"#\"><img title=\"查看" + searchFriends[index].cbname + "的详细资料\" style=\"width:60px;height:50px;border:none\" src=\"" + searchFriends[index].ImgPath + "\"/></a>";
                                bodyHtml += "</td>";
                                bodyHtml += "<td style=\"width:60px;\">";
                                bodyHtml += "<div><a href=\"#\">" + searchFriends[index].cbname + "</a></div>";
                                bodyHtml += "<div><a href=\"#\" onclick=\"showaddNewFriends('" + searchFriends[index].cbuserid + "','" + searchFriends[index].cbname + "','" + searchFriends[index].ImgPath + "');\">加为好友</a></div>";
                                bodyHtml += "</td>";
                                bodyHtml += "<td style=\"width:80px;\">&nbsp;</td>";
                                bodyHtml += "</tr></table>"
                                newTdEle.innerHTML = bodyHtml;
                                newTrEle.appendChild(newTdEle);
                                index++;
                            }
                        }
                        newTableEle .appendChild(newTrEle);
                    }

                    newDivEle.appendChild(newTableEle );
                    if (SysAgent.ie) {
                        systemcommendfriendsdiv.innerHTML += newDivEle.outerHTML+"<br/>";
                    }
                    else {
                        systemcommendfriendsdiv.appendChild(newDivEle);
                        systemcommendfriendsdiv.appendChild(document.createElement("br"));
                    }
                    //systemcommendfriendsdiv.innerHTML += newDivEle.outerHTML;
                }
            }
        }

        function showaddNewFriends(friendsId, friendsName, friendImgPath) {
            var currentUserId = AjaxFunction.GetCurrentUserId().value;
            if (currentUserId != null && currentUserId != "") {
                var mtop = parseInt(250) + "px";
                var mleft = parseInt(350) + "px";
                initAddFriendDiv(friendsId, friendsName, friendImgPath, currentUserId);
                popup_show('popup', 'popup_drag', 'popup_exit',mtop, mleft, true, 'maskDiv',50); 
            }
            else {
                clearAddFriendDiv();
                alert("对不起，您还未登录，请先登录！");
                window.location.href = "../member/login.aspx";
            } 
        }
        function clearAddFriendDiv() {
            document.getElementById("NewFriendImg").src = "";
            document.getElementById("NewFriendIdAnchor").innerHTML = "";
            document.getElementById("NewFriendIdHiddenInput").value = "";
            document.getElementById("FriendNickText").value = "";
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            friendGroupSelect.innerHTML = "";
            var newOptionEle = document.createElement("option");
            newOptionEle.innerHTML = "请选择分组";
            newOptionEle.value = "";
            newOptionEle.selected = "true";
            friendGroupSelect.appendChild(newOptionEle); 
        }
        function initAddFriendDiv(friendsId, friendsName,friendImgPath,currentUserid) {
            document.getElementById("NewFriendImg").src = friendImgPath;
            document.getElementById("NewFriendIdAnchor").innerHTML = friendsName;
            document.getElementById("NewFriendIdHiddenInput").value = friendsId;
            document.getElementById("FriendNickText").value = friendsName;
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");
            friendGroupSelect.innerHTML = "";
            var newOptionEle = document.createElement("option");
            var allGroupResult = AjaxFunction.GetCurrentGroupList();
            if (allGroupResult.value != null && allGroupResult.value != "") {
                var allGroupList = eval(allGroupResult.value);
                for (var i = 0; i < allGroupList.length; i++) {
                    newOptionEle = document.createElement("option");
                    if (i == 0)
                        newOptionEle.selected = "true";
                    newOptionEle.value = allGroupList[i].id;
                    newOptionEle.innerHTML = allGroupList[i].name;
                    friendGroupSelect.appendChild(newOptionEle );
                }
            }             
        }
        function addFriend() {
            var friendsName = document.getElementById("NewFriendIdAnchor").innerHTML;
            var friendsId = document.getElementById("NewFriendIdHiddenInput").value;
            var friendsNick = document.getElementById("FriendNickText").value;
            var friendGroupSelect = document.getElementById("NewFriendGroupSelect");

            if (friendsNick.replace(/\s/g, "") == "") {
                alert("对不起，好友昵称不能为空！");
                return false;
            }
            var friendsGroupId = friendGroupSelect[friendGroupSelect.selectedIndex].value;
            var result = AjaxFunction.AddNewFriend(friendsGroupId, friendsId, friendsNick);
            if (result.value != null && result.value == "") {
                initSystemRecommendFriends();
                updateBindPager();
                alert("添加成功");
                return true;
            }
            else {
                if (result.value == null)
                    alert("添加失败");
                else
                    alert(result.value);
                return false;
            }
        }

        //        编辑好友
        function showEditFriendInfoDiv(thisObj) {             
            var currentUserId = AjaxFunction.GetCurrentUserId().value;
            if (currentUserId != null && currentUserId != "") {
                var grouprecidHidden = thisObj.parentNode.getElementsByTagName("input")[0];
                var imgPathHidden = thisObj.parentNode.getElementsByTagName("input")[1]
                initEditFriendInfoDiv(grouprecidHidden.value, imgPathHidden.value);
                var mtop = parseInt(250) + "px";
                var mleft = parseInt(350) + "px";
                //initAddFriendDiv(friendsId, friendsName, friendImgPath, currentUserId);
                popup_show('edit_popup', 'edit_popup_drag', 'edit_popup_exit',mtop, mleft, true, 'maskDiv',50); 
            }
            else {
                clearEditFriendInfoDiv();
                alert("对不起，您还未登录，请先登录！");
                window.location.href = "../member/login.aspx";
            }  
        }

        function initEditFriendInfoDiv(groupRecid,imgPath) {
            var result = AjaxFunction.GetGroupFriend(groupRecid);
            if (result.value != null && result.value != "") {
                var groupFriend = eval("("+result.value+")");
                document.getElementById("EditFriendNameAnchor").innerHTML = groupFriend.username;
                document.getElementById("EditFriendGroupListIdHidden").value = groupRecid;
                document.getElementById("EditFriendOldNickText").value = groupFriend.username;
                document.getElementById("EditFriendNewNickText").value = groupFriend.username;
                document.getElementById("EditFriendImg").src = imgPath;
                
                var oldFriendGroupId = groupFriend .groupid;
                var newfriendGroupSelect = document.getElementById("EditFriendGroupNewSelect");
                var oldfriendGroupSelect = document.getElementById("EditFriendGroupOldSelect");
                newfriendGroupSelect.innerHTML = "";
                oldfriendGroupSelect.innerHTML = "";
                var newOptionEle = document.createElement("option");
                var oldOptionEle = document.createElement("option");
                var allGroupResult = AjaxFunction.GetCurrentGroupList();
                if (allGroupResult.value != null && allGroupResult.value != "") {
                    var allGroupList = eval(allGroupResult.value);
                    for (var i = 0; i < allGroupList.length; i++) {
                        newOptionEle = document.createElement("option");
                        if (i == 0)
                            newOptionEle.selected = "true";
                        newOptionEle.value = allGroupList[i].id;
                        newOptionEle.innerHTML = allGroupList[i].name;
                        newfriendGroupSelect.appendChild(newOptionEle);

                        oldOptionEle = document.createElement("option");
                        if (allGroupList[i].id == oldFriendGroupId)
                            oldOptionEle.selected = "true";
                        oldOptionEle.value = allGroupList[i].id;
                        oldOptionEle.innerHTML = allGroupList[i].name;
                        oldfriendGroupSelect.appendChild(oldOptionEle);
                    }
                }
            } 
        }
        function clearEditFriendInfoDiv() {
            document.getElementById("EditFriendNameAnchor").innerHTML ="";
            document.getElementById("EditFriendGroupListIdHidden").value = "";
            document.getElementById("EditFriendOldNickText").value = "";
            document.getElementById("EditFriendNewNickText").value = "";
            document.getElementById("EditFriendImg").src = "";

            var oldFriendGroupId = groupFriend.groupid;
            var newfriendGroupSelect = document.getElementById("EditFriendGroupNewSelect");
            var oldfriendGroupSelect = document.getElementById("EditFriendGroupOldSelect");
            newfriendGroupSelect.innerHTML = "";
            oldfriendGroupSelect.innerHTML = "";
        }        
        function editFriend() {
            var friendsGroupListRecId = document.getElementById("EditFriendGroupListIdHidden").value;
            var friendsNick = document.getElementById("EditFriendNewNickText").value;
            var friendGroupSelect = document.getElementById("EditFriendGroupNewSelect");
            var friendsGroupId = friendGroupSelect[friendGroupSelect.selectedIndex].value;

            if (friendsNick.replace(/\s/g, "") == "") {
                alert("对不起，好友昵称不能为空！");
                return false;
            }
            
            var result = AjaxFunction.EditFriendInfo(friendsGroupListRecId, friendsNick, friendsGroupId);
            if (result.value != null && result.value == "") {
                updateBindPager();
                alert("修改成功");
                return true;
            }
            else {
                if (result.value == null)
                    alert("修改失败");
                else
                    alert(result.value);
                return false;
            }
        }

        initSystemRecommendFriends(); 
        initWidthAndHeight();
        function initWidthAndHeight() {
            document.getElementById("MasterDiv").style.width = screen.availWidth - 200 + "px";
        }
    </script>
</asp:Content>
